from collections import Counter
from aseg import seg,seg_tag,word_segment

def word_freq(text,word_max_num,word_min_freq):
    # print(seg(text))
    seglist = word_segment(text)
    # seglist = seg_tag(text)
    # print(seglsit)
    resdic = {}
    num = word_max_num
    segdic = Counter(seglist)

    for key, value in segdic.items():
        if len(key) > 1 and value > word_min_freq:
            resdic[key] = value
            num -= 1
        if num == 0:
            break
    return resdic



name = '1'
with open('doc/'+name+".txt", 'r', encoding='UTF-8') as f:
    text = f.read()
    f.close()

dic1 = word_freq(text,50,1)
print(dic1)